package com.cykj.controller;

import com.cykj.bean.MessageBean;
import com.cykj.bean.Tblroomuser;
import com.cykj.service.GameService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/game")
public class GameRoomController {
    @Autowired
    private GameService gameService;

    @RequestMapping("/find")
    public MessageBean selectroom(int roomid){
        List<Tblroomuser> list =gameService.selectroom(roomid);
        MessageBean messageBean = new MessageBean(200,"sussess",list);
        return messageBean;
    }

    @RequestMapping("/finduser")
    public MessageBean selectuser(int userid){
        List<Tblroomuser> list =gameService.selectuser(userid);
        MessageBean messageBean = new MessageBean(200,"sussess",list);
        return messageBean;
    }

    @RequestMapping("/updreldy")

    public MessageBean updreldy(int userid){
        int flag =gameService.updreldy(userid);
        MessageBean messageBean = new MessageBean(200,"sussess",flag);
        return messageBean;
    }

    @RequestMapping("/updcancel")

    public MessageBean updcancel(int userid){
        int flag =gameService.updcancel(userid);
        MessageBean messageBean = new MessageBean(200,"sussess",flag);
        return messageBean;
    }
    @RequestMapping("/findout")

    public MessageBean findout(int userid){
        List<Tblroomuser> list= gameService.selectout(userid);
        MessageBean messageBean = new MessageBean(200,"sussess",list);
        return messageBean;
    }

    @RequestMapping("getout")

    public MessageBean getout(int userid){
        int flag = gameService.getout(userid);
        MessageBean messageBean = new MessageBean(200,"sussess",flag);
        return messageBean;
    }

    @RequestMapping("/roomowner")

    public MessageBean roomowner(int roomid){
        int flag = gameService.roomowner(roomid);
        MessageBean messageBean =new MessageBean(200,"sussess",flag);

        return messageBean;
    }

    @RequestMapping("/countRoom")
    public MessageBean countRoom(int roomid){
        return MessageBean.success("",gameService.countRoomUser(roomid));
    }
}
